﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HFController;
using System.Web.Script.Serialization;
namespace HFWebApp.AjaxSource
{
    /// <summary>
    /// LayerSource 的摘要说明
    /// </summary>
    public class LayerSource : IHttpHandler
    {
        
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int typeid = int.Parse(context.Request["type"].ToString());

            List<hf.Model.Lawyer> layerlist = new List<hf.Model.Lawyer>();

            switch (typeid)
            { 
                case 0:
                    layerlist = HFController.LawyerController.getController().getLawyerList(6, "LoginCount");
                    break;
                case 1:
                    layerlist = HFController.LawyerController.getController().getLawyerList(6, "Point");
                    break;
                case 2:
                    layerlist = HFController.LawyerController.getController().getLawyerList(12, "LastLoginTime");
                    break;
                case 3:
                    int classid = int.Parse(context.Request["classid"].ToString());
                    layerlist = HFController.LawyerController.getController().getLayerList(1, 0, classid);
                    break;
                case 4:
                    int classid2 = int.Parse(context.Request["classid"].ToString());
                    layerlist = HFController.LawyerController.getController().getLayerList(12, 0, classid2);
                    break;
            }
            
            context.Response.Write(this.getJSONResult(layerlist));
            context.Response.End();
        }

        protected string getJSONResult(List<hf.Model.Lawyer> result)
        {
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer(new SimpleTypeResolver());
            return jsSerializer.Serialize(result);
        }


        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}